﻿<%--<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CRM.Models.TrainingsSchedules>" %>--%>
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CRM.Database.Model.TrainingsSchedules>" %>
<%@ Import Namespace="CRM.Resourses" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%: Resourses.TrainingsSchedule %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2><%: Resourses.TrainingsSchedule%> <%if(Model.IsActual) {%> (Изменение) <%}%> </h2>


<%
    var citiesCol = new CRM.Database.Model.TrainingsCitiesCollection();
    var regionsCol = new CRM.Database.Model.profineRegionsCollection();
    var statusesCol = new CRM.Database.Model.TrainingCoursesStatusesCollection();
%>

<%if(!Model.IsActual)
   {%>
       <%: Html.Partial("TrainingsSchedulesDisplayOnly", Model) %>
       <br/>
 <%}%>

<table>
    <tr>
        <td>
            Стоимость курса: <%= Model.CourseCost %>
        </td>
    </tr>
    <tr>
        <td>
            <%: Html.ActionLink("Печать заявки в cлужбу сервиса на обеспечение кофе-пауз", "TrainingsScheduleReportPrint", new { idSchedule = Model.IdTrainingsSchedule, template = "coffee_brake_service.docx" })%>
        </td>
    </tr>
    <tr>
        <td>
            <%: Html.ActionLink("Печать регистрационной формы", "TrainingsScheduleReportPrint", new { idSchedule = Model.IdTrainingsSchedule, template = "registration_form.docx" })%>
        </td>
    </tr>
    <tr>
        <td>
            <%: Html.ActionLink("Печать списка участников для охраны", "TrainingsScheduleReportPrint", new { idSchedule = Model.IdTrainingsSchedule, template = "members_list.docx" })%>
        </td>
    </tr>
</table>




<%using (Html.BeginForm("TrainingsSchedulesEdit", "TC", FormMethod.Post, new { @class = "edit_form" }))
      {
          Html.ValidationSummary(true);
      %>
<%: Html.Hidden("IdTrainingsSchedule")%> 
<%--<%: Html.Hidden("IdTrainingCoursesStatus")%> --%>

<%if(Model.IsActual)
    { %>

        <table>
            <tr>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Название курса";
                              //settings.AssociatedControlName = "Name";
                              settings.Width = 604;
                          }).GetHtml() %>
                    <%:Html.Partial("TrainingsSchedulesEditCoursesPartial", Model)%>
                </td>
            </tr>
        </table>

        <table>
            <tr>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Тренер";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.Partial("TrainingsSchedulesEditTrainersPartial", Model)%>           
                </td>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Площадка";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.Partial("TrainingsSchedulesEditPlacesPartial", Model)%> 
                </td>
            </tr>
            <tr>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                        {
                            settings.ControlStyle.CssClass = "lable";
                            settings.Text = "Плановая дата";
                            settings.Width = 300;
                        }).GetHtml() %>
                    <%:Html.DevExpress().DateEdit(settings =>
                        {
                            settings.Name = "PlannedDate";
                            settings.Properties.DisplayFormatString = "D";
                            settings.Width = 300;
                        }).Bind(Model.PlannedDate).GetHtml() %>
                </td>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Стоимость курса";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.DevExpress().SpinEdit(settings =>
                        {
                            settings.Name = "CourseCost";
                            settings.Properties.DisplayFormatString = "c";
                            settings.Properties.DisplayFormatInEditMode = true;
                            settings.Properties.MinValue = 0;
                            settings.Properties.MaxValue = 1000000;
                            settings.Width = 300;
                            settings.Properties.SpinButtons.ShowLargeIncrementButtons = true;
                        }).Bind(Model.CourseCost).GetHtml() %>
                </td>
            </tr>
            <%--<tr>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Стоимость участника";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.DevExpress().SpinEdit(settings =>
                        {
                            settings.Name = "ParticipantCost";
                            settings.Properties.DisplayFormatString = "c";
                            settings.Properties.DisplayFormatInEditMode = true;
                            settings.Properties.MinValue = 0;
                            settings.Properties.MaxValue = 1000000;
                            settings.Width = 300;
                            settings.Properties.SpinButtons.ShowLargeIncrementButtons = true;
                        }).Bind(Model.ParticipantCost).GetHtml() %>
                </td>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Фактическое кол-во участников";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.DevExpress().SpinEdit(settings =>
                        {
                            settings.Name = "CountActual";
                            settings.Properties.DisplayFormatInEditMode = true;
                            settings.Width = 300;
                            settings.Properties.MinValue = 0;
                            settings.Properties.MaxValue = 1000000;
                            settings.Properties.SpinButtons.ShowLargeIncrementButtons = true;
                        }).Bind(Model.CountActual).GetHtml() %>
                </td>
            </tr>--%>
            <%--<tr>
                <td>
                    <%:Html.DevExpress().Label(
                      settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Одобренное кол-во участников";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.DevExpress().SpinEdit(settings =>
                        {
                            settings.Name = "CountApproved";
                            settings.Properties.DisplayFormatInEditMode = true;
                            settings.Properties.MinValue = 0;
                            settings.Width = 300;
                            settings.Properties.MaxValue = 1000000;
                            settings.Properties.SpinButtons.ShowLargeIncrementButtons = true;
                        }).Bind(Model.CountApproved).GetHtml() %>
                </td>
                <td>
                    <%:Html.DevExpress().Label(
                      settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Заявленное кол-во участников";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.DevExpress().SpinEdit(settings =>
                        {
                            settings.Name = "CountRequested";
                            settings.Properties.DisplayFormatInEditMode = true;
                            settings.Properties.MinValue = 0;
                            settings.Properties.MaxValue = 1000000;
                            settings.Width = 300;
                            settings.Properties.SpinButtons.ShowLargeIncrementButtons = true;
                        }).Bind(Model.CountRequested).GetHtml() %>
                </td>
            </tr>--%>
            <tr>
                <%--<td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Допустимое кол-во участников";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.DevExpress().SpinEdit(settings =>
                        {
                            settings.Name = "CountAvailable";
                            settings.Properties.DisplayFormatInEditMode = true;
                            settings.Properties.MinValue = 0;
                            settings.Properties.MaxValue = 1000000;
                            settings.Width = 300;
                            settings.Properties.SpinButtons.ShowLargeIncrementButtons = true;
                        }).Bind(Model.CountAvailable).GetHtml() %>
                </td>--%>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Регион профайн";
                              settings.Width = 300;
                          }).GetHtml()%>
                    <%: Html.DevExpress().ComboBox(settings =>
                          {
                              settings.Name = "IdProfineRegion";
                              settings.ControlStyle.CssClass = "editor";
                              settings.Properties.TextField = "NameRu";
                              settings.Properties.ValueField = "IdProfineRegion";
                              settings.Properties.ValueType = typeof (int);
                              settings.Width = 300;
                          }).BindList(regionsCol.profineRegionsList).Bind(Model.IdProfineRegion).GetHtml()%>
                          <%--}).BindList(DB.profineRegionsActive).Bind(Model.IdProfineRegion).GetHtml()%>--%>
                </td>
        
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Город";
                              settings.Width = 300;
                          }).GetHtml()%>
                    <%: Html.DevExpress().ComboBox(settings =>
                          {
                              settings.Name = "IdTrainingsCity";
                              settings.ControlStyle.CssClass = "editor";
                              settings.Properties.TextField = "TrainingsCityName";
                              settings.Properties.ValueField = "IdTrainingsCity";
                              settings.Properties.ValueType = typeof (int);
                              settings.Width = 300;
                          }).BindList(citiesCol.TrainingsCitiesList.OrderBy(p => p.TrainingsCityName)).Bind(Model.IdTrainingsCity).GetHtml()%>
                          <%--}).BindList(DB.TrainingsCities.ToList().OrderBy(p=>p.TrainingsCityName)).Bind(Model.IdTrainingsCity).GetHtml()%>--%>
                </td>
            </tr>
            <tr>
                <td>
                    <%:Html.DevExpress().Label(settings =>
                          {
                              settings.ControlStyle.CssClass = "lable";
                              settings.Text = "Тип курса";
                              settings.Width = 300;
                          }).GetHtml() %>
                    <%:Html.Partial("TrainingsSchedulesEditCourseTypePartial", Model)%>
                </td>
                <td>
                    <%
                        if(Model.IdTrainingsSchedule > 0)
                        {
                            Html.DevExpress().Label(settings =>
                                                        {
                                                            settings.ControlStyle.CssClass = "lable";
                                                            settings.Text = "Статус";
                                                            settings.Width = 300;
                                                        }).GetHtml();
                        }
                    %>
                    <%
                        if(Model.IdTrainingsSchedule > 0)
                        {
                            Html.DevExpress().ComboBox(settings =>
                                                           {
                                                               settings.Name = "IdTrainingCoursesStatus";
                                                               settings.ControlStyle.CssClass = "editor";
                                                               settings.Properties.TextField = "NameRu";
                                                               settings.Properties.ValueField = "IdTrainingCoursesStatus";
                                                               settings.Properties.ValueType = typeof (int);
                                                               settings.Width = 300;
                                                           }).BindList(statusesCol.TrainingCoursesStatusesActiveList).Bind(Model.IdTrainingCoursesStatus).GetHtml();
                                                           //}).BindList(DB.TrainingCoursesStatuses).Bind(Model.IdTrainingCoursesStatus).GetHtml();
                        }
                    %>
                </td>
            </tr>
        </table>






        <div class="line">
              <%  Html.DevExpress().Label(
                      settings =>
                          {
                              settings.ControlStyle.CssClass = "label";
                          }
                      ).GetHtml();%>

        <table>
            <tr>
                <td>
                    <%Html.DevExpress().Button(settings =>
                          {
                              settings.Name = "btnUpdate";
                              settings.ControlStyle.CssClass = "button";
                              settings.Text = "Сохранить";
                              settings.UseSubmitBehavior = true;
                          }
                      ).GetHtml();%>
                </td>
                <td>
                    <%Html.DevExpress().Button(settings =>
                          {
                              settings.Name = "btnCancel";
                              settings.ControlStyle.CssClass = "button";
                              settings.Text = "Отмена";
                              settings.ClientSideEvents.Click = "function(s, e){ document.location='" +
                                                                DevExpressHelper.GetUrl(
                                                                    new { Controller = "TC", Action = "TrainingsSchedules" }) + "'; }";
                          }
                      ).GetHtml();%>
                </td>
        
            </tr>
        </table>
        </div>

<% } %>

<% if(Model.IdTrainingsSchedule > 0)
   {%>
    <table>
                <tr>
                    <td>
                        Стоимость участника:
                    </td>
                    <td>
                        <%= Model.ParticipantCoctExt%>
                    </td>
                    <td>
                        Допустимое кол-во участников:
                    </td>
                    <td>
                        <%= Model.ParticipantsCountAvailable %>
                    </td>
                </tr>
    </table>
    <table>
        <tr>
            <td>
                Участники
            </td>
        </tr>
        <tr>
            <td>
                <%: Html.Partial("TrainingsParticipantsListPartial", Model.IdTrainingsSchedule) %>
            </td>
        </tr>
    </table>

 <%}%>

<% } %>

</asp:Content>
